from typing import Dict, Any, List
from .base_service_handler import BaseServiceHandler, ServiceHandlerFactory

class FTPServiceHandler(BaseServiceHandler):
    """FTP服务信息处理器"""
    
    def get_service_details(self, service_info: Dict[str, Any]) -> List[str]:
        """获取FTP服务的详细信息"""
        details = []
        
        # 基本信息
        if service_info.get('product'):
            details.append(f"产品: {self._safe_str(service_info['product'])}")
        if service_info.get('version'):
            details.append(f"版本: {self._safe_str(service_info['version'])}")
        if service_info.get('banner'):
            details.append(f"Banner: {self._safe_str(service_info['banner'])}")
            
        # FTP特定信息
        if service_info.get('os_type'):
            details.append(f"操作系统: {self._safe_str(service_info['os_type'])}")
        if service_info.get('anonymous') is not None:
            details.append(f"匿名访问: {'允许' if service_info['anonymous'] else '禁止'}")
        if service_info.get('features'):
            details.append(f"支持特性: {', '.join(map(self._safe_str, service_info['features']))}")
            
        return details

# 注册FTP服务处理器
ServiceHandlerFactory.register_handler('ftp', FTPServiceHandler) 